

<!DOCTYPE html>
<!--[if IE 8]><html class="no-js lt-ie9" lang="en" > <![endif]-->
<!--[if gt IE 8]><!--> <html class="no-js" lang="en" > <!--<![endif]-->
<head>
  <meta charset="utf-8">
  
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  
  <title>data &mdash; OpenChem 0.1 documentation</title>
  

  
  
  
  

  
  <script type="text/javascript" src="../_static/js/modernizr.min.js"></script>
  
    
      <script type="text/javascript" id="documentation_options" data-url_root="../" src="../_static/documentation_options.js"></script>
        <script src="../_static/jquery.js"></script>
        <script src="../_static/underscore.js"></script>
        <script src="../_static/doctools.js"></script>
        <script src="../_static/language_data.js"></script>
        <script async="async" src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.7/latest.js?config=TeX-AMS-MML_HTMLorMML"></script>
    
    <script type="text/javascript" src="../_static/js/theme.js"></script>

    

  
  <link rel="stylesheet" href="../_static/css/theme.css" type="text/css" />
  <link rel="stylesheet" href="../_static/pygments.css" type="text/css" />
    <link rel="index" title="Index" href="../genindex.html" />
    <link rel="search" title="Search" href="../search.html" />
    <link rel="next" title="criterion" href="criterion.html" />
    <link rel="prev" title="layers" href="layers.html" /> 
</head>

<body class="wy-body-for-nav">

   
  <div class="wy-grid-for-nav">
    
    <nav data-toggle="wy-nav-shift" class="wy-nav-side">
      <div class="wy-side-scroll">
        <div class="wy-side-nav-search" >
          

          
            <a href="../index.html">
          

          
            
            <img src="../_static/logo.png" class="logo" alt="Logo"/>
          
          </a>

          

          
<div role="search">
  <form id="rtd-search-form" class="wy-form" action="../search.html" method="get">
    <input type="text" name="q" placeholder="Search docs" />
    <input type="hidden" name="check_keywords" value="yes" />
    <input type="hidden" name="area" value="default" />
  </form>
</div>

          
        </div>

        <div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="main navigation">
          
            
            
              
            
            
              <ul class="current">
<li class="toctree-l1"><a class="reference internal" href="../index.html">Introduction</a></li>
<li class="toctree-l1"><a class="reference internal" href="../installation_instructions.html">Installation instructions</a><ul>
<li class="toctree-l2"><a class="reference internal" href="../installation_instructions.html#general-installation">General installation</a></li>
<li class="toctree-l2"><a class="reference internal" href="../installation_instructions.html#installation-with-docker">Installation with Docker</a></li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="../how_to_run_tutorial.html">How to define and train models</a><ul>
<li class="toctree-l2"><a class="reference internal" href="../how_to_run_tutorial.html#arguments-for-launch-py">Arguments for launch.py</a></li>
<li class="toctree-l2"><a class="reference internal" href="../how_to_run_tutorial.html#arguments-for-run-py">Arguments for run.py</a></li>
<li class="toctree-l2"><a class="reference internal" href="../how_to_run_tutorial.html#configuration-file">Configuration file</a></li>
<li class="toctree-l2"><a class="reference internal" href="../how_to_run_tutorial.html#launching-jobs">Launching jobs</a></li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="../tutorials/blocks.html">Tutorials and Recipes</a><ul>
<li class="toctree-l2"><a class="reference internal" href="../tutorials/getting_started.html">Getting started with building models in OpenChem</a><ul>
<li class="toctree-l3"><a class="reference internal" href="../tutorials/getting_started.html#loading-data">Loading data</a></li>
<li class="toctree-l3"><a class="reference internal" href="../tutorials/getting_started.html#creating-pytorch-dataset">Creating PyTorch dataset</a></li>
<li class="toctree-l3"><a class="reference internal" href="../tutorials/getting_started.html#creating-openchem-model-and-specifying-parameters">Creating OpenChem model and specifying parameters</a></li>
<li class="toctree-l3"><a class="reference internal" href="../tutorials/getting_started.html#training-the-model">Training the model</a></li>
</ul>
</li>
<li class="toctree-l2"><a class="reference internal" href="../tutorials/gcnn_tutorial.html">GraphCNN for predicting logP</a><ul>
<li class="toctree-l3"><a class="reference internal" href="../tutorials/gcnn_tutorial.html#defining-node-attributes">Defining node attributes</a></li>
<li class="toctree-l3"><a class="reference internal" href="../tutorials/gcnn_tutorial.html#loading-data">Loading data</a></li>
<li class="toctree-l3"><a class="reference internal" href="../tutorials/gcnn_tutorial.html#defining-model-architechture">Defining model architechture</a></li>
<li class="toctree-l3"><a class="reference internal" href="../tutorials/gcnn_tutorial.html#training-and-evaluating-the-model">Training and evaluating the model</a></li>
</ul>
</li>
<li class="toctree-l2"><a class="reference internal" href="../tutorials/tox21_tutorial.html">Tox21 Challenge</a><ul>
<li class="toctree-l3"><a class="reference internal" href="../tutorials/tox21_tutorial.html#loading-data">Loading data</a></li>
<li class="toctree-l3"><a class="reference internal" href="../tutorials/tox21_tutorial.html#defining-evaluation-function">Defining evaluation function</a></li>
<li class="toctree-l3"><a class="reference internal" href="../tutorials/tox21_tutorial.html#defining-model-architechture">Defining model architechture</a></li>
<li class="toctree-l3"><a class="reference internal" href="../tutorials/tox21_tutorial.html#training-and-evaluating-the-model">Training and evaluating the model</a></li>
</ul>
</li>
</ul>
</li>
<li class="toctree-l1 current"><a class="reference internal" href="blocks.html">API documentation</a><ul class="current">
<li class="toctree-l2"><a class="reference internal" href="models.html">models</a><ul>
<li class="toctree-l3"><a class="reference internal" href="models.html#module-models.openchem_model">openchem_model</a></li>
<li class="toctree-l3"><a class="reference internal" href="models.html#module-models.Smiles2Label">Smiles2Label</a></li>
<li class="toctree-l3"><a class="reference internal" href="models.html#module-models.Graph2Label">Graph2Label</a></li>
<li class="toctree-l3"><a class="reference internal" href="models.html#module-models.MoleculeProtein2Label">MoleculeProtein2Label</a></li>
<li class="toctree-l3"><a class="reference internal" href="models.html#vanilla-model">vanilla_model</a></li>
</ul>
</li>
<li class="toctree-l2"><a class="reference internal" href="modules.html">modules</a><ul>
<li class="toctree-l3"><a class="reference internal" href="modules.encoders.html">encoders</a><ul>
<li class="toctree-l4"><a class="reference internal" href="modules.encoders.html#module-modules.encoders.openchem_encoder">openchem_encoder</a></li>
<li class="toctree-l4"><a class="reference internal" href="modules.encoders.html#module-modules.encoders.rnn_encoder">rnn_encoder</a></li>
<li class="toctree-l4"><a class="reference internal" href="modules.encoders.html#cnn-encoder">cnn_encoder</a></li>
<li class="toctree-l4"><a class="reference internal" href="modules.encoders.html#gcnn-encoder">gcnn_encoder</a></li>
</ul>
</li>
<li class="toctree-l3"><a class="reference internal" href="modules.embeddings.html">embeddings</a><ul>
<li class="toctree-l4"><a class="reference internal" href="modules.embeddings.html#module-modules.embeddings.openchem_embedding">openchem_embedding</a></li>
<li class="toctree-l4"><a class="reference internal" href="modules.embeddings.html#module-modules.embeddings.basic_embedding">basic_embedding</a></li>
<li class="toctree-l4"><a class="reference internal" href="modules.embeddings.html#positional-embedding">positional_embedding</a></li>
</ul>
</li>
<li class="toctree-l3"><a class="reference internal" href="modules.mlp.html">mlp</a></li>
</ul>
</li>
<li class="toctree-l2"><a class="reference internal" href="layers.html">layers</a><ul>
<li class="toctree-l3"><a class="reference internal" href="layers.html#module-layers.conv_bn_relu">conv_bn_relu</a></li>
<li class="toctree-l3"><a class="reference internal" href="layers.html#module-layers.gcn">gcn</a></li>
</ul>
</li>
<li class="toctree-l2 current"><a class="current reference internal" href="#">data</a><ul>
<li class="toctree-l3"><a class="reference internal" href="#module-data.smiles_data_layer">smiles_data_layer</a></li>
<li class="toctree-l3"><a class="reference internal" href="#graph-data-layer">graph_data_layer</a></li>
<li class="toctree-l3"><a class="reference internal" href="#module-data.smiles_protein_data_layer">smiles_protein_data_layer</a></li>
<li class="toctree-l3"><a class="reference internal" href="#module-data.vanilla_data_layer">vanilla_data_layer</a></li>
<li class="toctree-l3"><a class="reference internal" href="#module-data.smiles_enumerator">smiles_enumerator</a></li>
<li class="toctree-l3"><a class="reference internal" href="#module-data.utils">utils</a></li>
</ul>
</li>
<li class="toctree-l2"><a class="reference internal" href="criterion.html">criterion</a><ul>
<li class="toctree-l3"><a class="reference internal" href="criterion.html#module-openchem.criterion.multitask_loss">multitask_loss</a></li>
</ul>
</li>
<li class="toctree-l2"><a class="reference internal" href="optimizer.html">optimizer</a><ul>
<li class="toctree-l3"><a class="reference internal" href="optimizer.html#module-optimizer.openchem_optimizer">openchem_optimizer</a></li>
<li class="toctree-l3"><a class="reference internal" href="optimizer.html#module-optimizer.openchem_lr_scheduler">openchem_lr_scheduler</a></li>
</ul>
</li>
<li class="toctree-l2"><a class="reference internal" href="utils.html">utils</a><ul>
<li class="toctree-l3"><a class="reference internal" href="utils.html#module-openchem.utils.graph">graph</a></li>
<li class="toctree-l3"><a class="reference internal" href="utils.html#id1">utils</a></li>
<li class="toctree-l3"><a class="reference internal" href="utils.html#logger">logger</a></li>
</ul>
</li>
</ul>
</li>
</ul>

            
          
        </div>
      </div>
    </nav>

    <section data-toggle="wy-nav-shift" class="wy-nav-content-wrap">

      
      <nav class="wy-nav-top" aria-label="top navigation">
        
          <i data-toggle="wy-nav-top" class="fa fa-bars"></i>
          <a href="../index.html">OpenChem</a>
        
      </nav>


      <div class="wy-nav-content">
        
        <div class="rst-content">
        
          















<div role="navigation" aria-label="breadcrumbs navigation">

  <ul class="wy-breadcrumbs">
    
      <li><a href="../index.html">Docs</a> &raquo;</li>
        
          <li><a href="blocks.html">API documentation</a> &raquo;</li>
        
      <li>data</li>
    
    
      <li class="wy-breadcrumbs-aside">
        
            
            <a href="../_sources/api-docs/data.rst.txt" rel="nofollow"> View page source</a>
          
        
      </li>
    
  </ul>

  
  <hr/>
</div>
          <div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article">
           <div itemprop="articleBody">
            
  <div class="section" id="module-data">
<span id="data"></span><h1>data<a class="headerlink" href="#module-data" title="Permalink to this headline">¶</a></h1>
<div class="section" id="module-data.smiles_data_layer">
<span id="smiles-data-layer"></span><h2>smiles_data_layer<a class="headerlink" href="#module-data.smiles_data_layer" title="Permalink to this headline">¶</a></h2>
<dl class="py class">
<dt id="data.smiles_data_layer.SmilesDataset">
<em class="property">class </em><code class="sig-prename descclassname">data.smiles_data_layer.</code><code class="sig-name descname">SmilesDataset</code><span class="sig-paren">(</span><em class="sig-param"><span class="o">*</span><span class="n">args</span></em>, <em class="sig-param"><span class="o">**</span><span class="n">kwds</span></em><span class="sig-paren">)</span><a class="reference internal" href="../_modules/data/smiles_data_layer.html#SmilesDataset"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#data.smiles_data_layer.SmilesDataset" title="Permalink to this definition">¶</a></dt>
<dd><p>Bases: <code class="xref py py-class docutils literal notranslate"><span class="pre">torch.utils.data.dataset.Dataset</span></code></p>
<p>Creates dataset for SMILES-property data.
:param filename: string with full path to dataset file. Dataset file</p>
<blockquote>
<div><p>must be csv file.</p>
</div></blockquote>
<dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>cols_to_read</strong> (<em>list</em>) – list specifying columns to read from dataset file.
Could be of various length, <cite>cols_to_read[0]</cite> will be used as index
as index for column with SMILES, <cite>cols_to_read[1:]</cite> will be used as
indices for labels values.</p></li>
<li><p><strong>delimiter</strong> (<em>str</em>) – columns delimiter in <cite>filename</cite>. <cite>default</cite> is <cite>,</cite>.</p></li>
<li><p><strong>tokens</strong> (<em>list</em>) – list of unique tokens from SMILES. If not specified, will
be extracted from provided dataset.</p></li>
<li><p><strong>pad</strong> (<em>bool</em>) – argument specifying whether to pad SMILES. If <cite>true</cite> SMILES
will be padded from right and the flipped. <cite>default</cite> is <cite>True</cite>.</p></li>
<li><p><strong>augment</strong> (<em>bool</em>) – argument specifying whether to augment SMILES.</p></li>
</ul>
</dd>
</dl>
</dd></dl>

</div>
<div class="section" id="graph-data-layer">
<h2>graph_data_layer<a class="headerlink" href="#graph-data-layer" title="Permalink to this headline">¶</a></h2>
</div>
<div class="section" id="module-data.smiles_protein_data_layer">
<span id="smiles-protein-data-layer"></span><h2>smiles_protein_data_layer<a class="headerlink" href="#module-data.smiles_protein_data_layer" title="Permalink to this headline">¶</a></h2>
<dl class="py class">
<dt id="data.smiles_protein_data_layer.SmilesProteinDataset">
<em class="property">class </em><code class="sig-prename descclassname">data.smiles_protein_data_layer.</code><code class="sig-name descname">SmilesProteinDataset</code><span class="sig-paren">(</span><em class="sig-param"><span class="o">*</span><span class="n">args</span></em>, <em class="sig-param"><span class="o">**</span><span class="n">kwds</span></em><span class="sig-paren">)</span><a class="reference internal" href="../_modules/data/smiles_protein_data_layer.html#SmilesProteinDataset"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#data.smiles_protein_data_layer.SmilesProteinDataset" title="Permalink to this definition">¶</a></dt>
<dd><p>Bases: <code class="xref py py-class docutils literal notranslate"><span class="pre">torch.utils.data.dataset.Dataset</span></code></p>
</dd></dl>

</div>
<div class="section" id="module-data.vanilla_data_layer">
<span id="vanilla-data-layer"></span><h2>vanilla_data_layer<a class="headerlink" href="#module-data.vanilla_data_layer" title="Permalink to this headline">¶</a></h2>
<dl class="py class">
<dt id="data.vanilla_data_layer.VanillaDataset">
<em class="property">class </em><code class="sig-prename descclassname">data.vanilla_data_layer.</code><code class="sig-name descname">VanillaDataset</code><span class="sig-paren">(</span><em class="sig-param"><span class="n">filename</span></em>, <em class="sig-param"><span class="n">cols_to_read</span></em>, <em class="sig-param"><span class="n">features</span></em>, <em class="sig-param"><span class="n">delimiter</span><span class="o">=</span><span class="default_value">','</span></em>, <em class="sig-param"><span class="n">tokens</span><span class="o">=</span><span class="default_value">None</span></em><span class="sig-paren">)</span><a class="reference internal" href="../_modules/data/vanilla_data_layer.html#VanillaDataset"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#data.vanilla_data_layer.VanillaDataset" title="Permalink to this definition">¶</a></dt>
<dd><p>Bases: <code class="xref py py-class docutils literal notranslate"><span class="pre">object</span></code></p>
</dd></dl>

</div>
<div class="section" id="module-data.smiles_enumerator">
<span id="smiles-enumerator"></span><h2>smiles_enumerator<a class="headerlink" href="#module-data.smiles_enumerator" title="Permalink to this headline">¶</a></h2>
<dl class="py class">
<dt id="data.smiles_enumerator.Iterator">
<em class="property">class </em><code class="sig-prename descclassname">data.smiles_enumerator.</code><code class="sig-name descname">Iterator</code><span class="sig-paren">(</span><em class="sig-param"><span class="n">n</span></em>, <em class="sig-param"><span class="n">batch_size</span></em>, <em class="sig-param"><span class="n">shuffle</span></em>, <em class="sig-param"><span class="n">seed</span></em><span class="sig-paren">)</span><a class="reference internal" href="../_modules/data/smiles_enumerator.html#Iterator"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#data.smiles_enumerator.Iterator" title="Permalink to this definition">¶</a></dt>
<dd><p>Bases: <code class="xref py py-class docutils literal notranslate"><span class="pre">object</span></code></p>
<p>Abstract base class for data iterators.
# Arguments</p>
<blockquote>
<div><p>n: Integer, total number of samples in the dataset to loop over.
batch_size: Integer, size of a batch.
shuffle: Boolean, whether to shuffle the data between epochs.
seed: Random seeding for data shuffling.</p>
</div></blockquote>
<dl class="py method">
<dt id="data.smiles_enumerator.Iterator.reset">
<code class="sig-name descname">reset</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference internal" href="../_modules/data/smiles_enumerator.html#Iterator.reset"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#data.smiles_enumerator.Iterator.reset" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

</dd></dl>

<dl class="py class">
<dt id="data.smiles_enumerator.SmilesEnumerator">
<em class="property">class </em><code class="sig-prename descclassname">data.smiles_enumerator.</code><code class="sig-name descname">SmilesEnumerator</code><span class="sig-paren">(</span><em class="sig-param"><span class="n">charset</span><span class="o">=</span><span class="default_value">'&#64;C)(=cOn1S2/H[N]\\'</span></em>, <em class="sig-param"><span class="n">pad</span><span class="o">=</span><span class="default_value">120</span></em>, <em class="sig-param"><span class="n">leftpad</span><span class="o">=</span><span class="default_value">True</span></em>, <em class="sig-param"><span class="n">isomericSmiles</span><span class="o">=</span><span class="default_value">True</span></em>, <em class="sig-param"><span class="n">enum</span><span class="o">=</span><span class="default_value">True</span></em>, <em class="sig-param"><span class="n">canonical</span><span class="o">=</span><span class="default_value">False</span></em><span class="sig-paren">)</span><a class="reference internal" href="../_modules/data/smiles_enumerator.html#SmilesEnumerator"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#data.smiles_enumerator.SmilesEnumerator" title="Permalink to this definition">¶</a></dt>
<dd><p>Bases: <code class="xref py py-class docutils literal notranslate"><span class="pre">object</span></code></p>
<p>SMILES Enumerator, vectorizer and devectorizer
#Arguments</p>
<blockquote>
<div><dl class="simple">
<dt>charset: string containing the characters for the vectorization</dt><dd><p>can also be generated via the .fit() method</p>
</dd>
</dl>
<p>pad: Length of the vectorization
leftpad: Add spaces to the left of the SMILES
isomericSmiles: Generate SMILES containing information about stereogenic centers
enum: Enumerate the SMILES during transform
canonical: use canonical SMILES during transform (overrides enum)</p>
</div></blockquote>
<dl class="py method">
<dt id="data.smiles_enumerator.SmilesEnumerator.charset">
<em class="property">property </em><code class="sig-name descname">charset</code><a class="headerlink" href="#data.smiles_enumerator.SmilesEnumerator.charset" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<dl class="py method">
<dt id="data.smiles_enumerator.SmilesEnumerator.fit">
<code class="sig-name descname">fit</code><span class="sig-paren">(</span><em class="sig-param"><span class="n">smiles</span></em>, <em class="sig-param"><span class="n">extra_chars</span><span class="o">=</span><span class="default_value">[]</span></em>, <em class="sig-param"><span class="n">extra_pad</span><span class="o">=</span><span class="default_value">5</span></em><span class="sig-paren">)</span><a class="reference internal" href="../_modules/data/smiles_enumerator.html#SmilesEnumerator.fit"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#data.smiles_enumerator.SmilesEnumerator.fit" title="Permalink to this definition">¶</a></dt>
<dd><p>Performs extraction of the charset and length of a SMILES datasets
and sets self.pad and self.charset
#Arguments</p>
<blockquote>
<div><p>smiles: Numpy array or Pandas series containing smiles as strings
extra_chars: List of extra chars to add to the charset
(e.g. “\” when “/” is present)
extra_pad: Extra padding to add before or after the
SMILES vectorization</p>
</div></blockquote>
</dd></dl>

<dl class="py method">
<dt id="data.smiles_enumerator.SmilesEnumerator.randomize_smiles">
<code class="sig-name descname">randomize_smiles</code><span class="sig-paren">(</span><em class="sig-param"><span class="n">smiles</span></em><span class="sig-paren">)</span><a class="reference internal" href="../_modules/data/smiles_enumerator.html#SmilesEnumerator.randomize_smiles"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#data.smiles_enumerator.SmilesEnumerator.randomize_smiles" title="Permalink to this definition">¶</a></dt>
<dd><p>Perform a randomization of a SMILES string
must be RDKit sanitizable</p>
</dd></dl>

<dl class="py method">
<dt id="data.smiles_enumerator.SmilesEnumerator.reverse_transform">
<code class="sig-name descname">reverse_transform</code><span class="sig-paren">(</span><em class="sig-param"><span class="n">vect</span></em><span class="sig-paren">)</span><a class="reference internal" href="../_modules/data/smiles_enumerator.html#SmilesEnumerator.reverse_transform"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#data.smiles_enumerator.SmilesEnumerator.reverse_transform" title="Permalink to this definition">¶</a></dt>
<dd><p>Performs a conversion of a vectorized SMILES to a smiles strings
charset must be the same as used for vectorization.
#Arguments</p>
<blockquote>
<div><p>vect: Numpy array of vectorized SMILES.</p>
</div></blockquote>
</dd></dl>

<dl class="py method">
<dt id="data.smiles_enumerator.SmilesEnumerator.transform">
<code class="sig-name descname">transform</code><span class="sig-paren">(</span><em class="sig-param"><span class="n">smiles</span></em><span class="sig-paren">)</span><a class="reference internal" href="../_modules/data/smiles_enumerator.html#SmilesEnumerator.transform"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#data.smiles_enumerator.SmilesEnumerator.transform" title="Permalink to this definition">¶</a></dt>
<dd><p>Perform an enumeration (randomization) and vectorization of
a Numpy array of smiles strings
#Arguments</p>
<blockquote>
<div><p>smiles: Numpy array or Pandas series containing smiles as strings</p>
</div></blockquote>
</dd></dl>

</dd></dl>

<dl class="py class">
<dt id="data.smiles_enumerator.SmilesIterator">
<em class="property">class </em><code class="sig-prename descclassname">data.smiles_enumerator.</code><code class="sig-name descname">SmilesIterator</code><span class="sig-paren">(</span><em class="sig-param">x</em>, <em class="sig-param">y</em>, <em class="sig-param">smiles_data_generator</em>, <em class="sig-param">batch_size=32</em>, <em class="sig-param">shuffle=False</em>, <em class="sig-param">seed=None</em>, <em class="sig-param">dtype=&lt;class 'numpy.float32'&gt;</em><span class="sig-paren">)</span><a class="reference internal" href="../_modules/data/smiles_enumerator.html#SmilesIterator"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#data.smiles_enumerator.SmilesIterator" title="Permalink to this definition">¶</a></dt>
<dd><p>Bases: <a class="reference internal" href="#data.smiles_enumerator.Iterator" title="data.smiles_enumerator.Iterator"><code class="xref py py-class docutils literal notranslate"><span class="pre">data.smiles_enumerator.Iterator</span></code></a></p>
<p>Iterator yielding data from a SMILES array.
# Arguments</p>
<blockquote>
<div><p>x: Numpy array of SMILES input data.
y: Numpy array of targets data.
smiles_data_generator: Instance of <cite>SmilesEnumerator</cite></p>
<blockquote>
<div><p>to use for random SMILES generation.</p>
</div></blockquote>
<p>batch_size: Integer, size of a batch.
shuffle: Boolean, whether to shuffle the data between epochs.
seed: Random seed for data shuffling.
dtype: dtype to use for returned batch.
Set to keras.backend.floatx if using Keras</p>
</div></blockquote>
<dl class="py method">
<dt id="data.smiles_enumerator.SmilesIterator.next">
<code class="sig-name descname">next</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference internal" href="../_modules/data/smiles_enumerator.html#SmilesIterator.next"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#data.smiles_enumerator.SmilesIterator.next" title="Permalink to this definition">¶</a></dt>
<dd><p>For python 2.x.
# Returns</p>
<blockquote>
<div><p>The next batch.</p>
</div></blockquote>
</dd></dl>

</dd></dl>

</div>
<div class="section" id="module-data.utils">
<span id="utils"></span><h2>utils<a class="headerlink" href="#module-data.utils" title="Permalink to this headline">¶</a></h2>
<dl class="py class">
<dt id="data.utils.DummyDataLoader">
<em class="property">class </em><code class="sig-prename descclassname">data.utils.</code><code class="sig-name descname">DummyDataLoader</code><span class="sig-paren">(</span><em class="sig-param"><span class="n">batch_size</span></em><span class="sig-paren">)</span><a class="reference internal" href="../_modules/data/utils.html#DummyDataLoader"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#data.utils.DummyDataLoader" title="Permalink to this definition">¶</a></dt>
<dd><p>Bases: <code class="xref py py-class docutils literal notranslate"><span class="pre">object</span></code></p>
</dd></dl>

<dl class="py class">
<dt id="data.utils.DummyDataset">
<em class="property">class </em><code class="sig-prename descclassname">data.utils.</code><code class="sig-name descname">DummyDataset</code><span class="sig-paren">(</span><em class="sig-param"><span class="o">*</span><span class="n">args</span></em>, <em class="sig-param"><span class="o">**</span><span class="n">kwds</span></em><span class="sig-paren">)</span><a class="reference internal" href="../_modules/data/utils.html#DummyDataset"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#data.utils.DummyDataset" title="Permalink to this definition">¶</a></dt>
<dd><p>Bases: <code class="xref py py-class docutils literal notranslate"><span class="pre">torch.utils.data.dataset.Dataset</span></code></p>
</dd></dl>

<dl class="py function">
<dt id="data.utils.augment_smiles">
<code class="sig-prename descclassname">data.utils.</code><code class="sig-name descname">augment_smiles</code><span class="sig-paren">(</span><em class="sig-param"><span class="n">smiles</span></em>, <em class="sig-param"><span class="n">labels</span></em>, <em class="sig-param"><span class="n">n_augment</span><span class="o">=</span><span class="default_value">5</span></em><span class="sig-paren">)</span><a class="reference internal" href="../_modules/data/utils.html#augment_smiles"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#data.utils.augment_smiles" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<dl class="py function">
<dt id="data.utils.canonize_smiles">
<code class="sig-prename descclassname">data.utils.</code><code class="sig-name descname">canonize_smiles</code><span class="sig-paren">(</span><em class="sig-param"><span class="n">smiles</span></em>, <em class="sig-param"><span class="n">sanitize</span><span class="o">=</span><span class="default_value">True</span></em><span class="sig-paren">)</span><a class="reference internal" href="../_modules/data/utils.html#canonize_smiles"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#data.utils.canonize_smiles" title="Permalink to this definition">¶</a></dt>
<dd><dl>
<dt>Takes list of SMILES strings and returns list of their canonical SMILES.</dt><dd><dl class="simple">
<dt>Args:</dt><dd><p>smiles (list): list of SMILES strings
sanitize (bool): parameter specifying whether to sanitize
SMILES or not.
For definition of sanitized SMILES check
www.rdkit.org/docs/api/rdkit.Chem.rdmolops-module.html#SanitizeMol</p>
</dd>
<dt>Output:</dt><dd><p>new_smiles (list): list of canonical SMILES and NaNs
if SMILES string is invalid or unsanitized
(when ‘sanitize = True’)</p>
</dd>
</dl>
<p>When ‘sanitize = True’ the function is analogous to:
sanitize_smiles(smiles, canonize=True).</p>
</dd>
</dl>
</dd></dl>

<dl class="py function">
<dt id="data.utils.create_loader">
<code class="sig-prename descclassname">data.utils.</code><code class="sig-name descname">create_loader</code><span class="sig-paren">(</span><em class="sig-param"><span class="n">dataset</span></em>, <em class="sig-param"><span class="n">batch_size</span></em>, <em class="sig-param"><span class="n">shuffle</span><span class="o">=</span><span class="default_value">True</span></em>, <em class="sig-param"><span class="n">num_workers</span><span class="o">=</span><span class="default_value">1</span></em>, <em class="sig-param"><span class="n">pin_memory</span><span class="o">=</span><span class="default_value">False</span></em>, <em class="sig-param"><span class="n">sampler</span><span class="o">=</span><span class="default_value">None</span></em><span class="sig-paren">)</span><a class="reference internal" href="../_modules/data/utils.html#create_loader"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#data.utils.create_loader" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<dl class="py function">
<dt id="data.utils.cut_padding">
<code class="sig-prename descclassname">data.utils.</code><code class="sig-name descname">cut_padding</code><span class="sig-paren">(</span><em class="sig-param"><span class="n">samples</span></em>, <em class="sig-param"><span class="n">lengths</span></em>, <em class="sig-param"><span class="n">padding</span><span class="o">=</span><span class="default_value">'left'</span></em><span class="sig-paren">)</span><a class="reference internal" href="../_modules/data/utils.html#cut_padding"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#data.utils.cut_padding" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<dl class="py function">
<dt id="data.utils.get_fp">
<code class="sig-prename descclassname">data.utils.</code><code class="sig-name descname">get_fp</code><span class="sig-paren">(</span><em class="sig-param"><span class="n">smiles</span></em>, <em class="sig-param"><span class="n">n_bits</span><span class="o">=</span><span class="default_value">2048</span></em><span class="sig-paren">)</span><a class="reference internal" href="../_modules/data/utils.html#get_fp"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#data.utils.get_fp" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<dl class="py function">
<dt id="data.utils.get_tokens">
<code class="sig-prename descclassname">data.utils.</code><code class="sig-name descname">get_tokens</code><span class="sig-paren">(</span><em class="sig-param"><span class="n">smiles</span></em>, <em class="sig-param"><span class="n">tokens</span><span class="o">=</span><span class="default_value">None</span></em><span class="sig-paren">)</span><a class="reference internal" href="../_modules/data/utils.html#get_tokens"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#data.utils.get_tokens" title="Permalink to this definition">¶</a></dt>
<dd><p>Returns list of unique tokens, token-2-index dictionary and
number of unique tokens from the list of SMILES
:param smiles: list of SMILES strings to tokenize.
:type smiles: list
:param tokens: string of tokens or None.
:type tokens: string
:param If none will be extracted from dataset.:</p>
<dl class="field-list simple">
<dt class="field-odd">Returns</dt>
<dd class="field-odd"><p>list of unique tokens/SMILES alphabet.
token2idx (dict): dictionary mapping token to its index.
num_tokens (int): number of unique tokens.</p>
</dd>
<dt class="field-even">Return type</dt>
<dd class="field-even"><p>tokens (list)</p>
</dd>
</dl>
</dd></dl>

<dl class="py function">
<dt id="data.utils.mol2image">
<code class="sig-prename descclassname">data.utils.</code><code class="sig-name descname">mol2image</code><span class="sig-paren">(</span><em class="sig-param"><span class="n">x</span></em>, <em class="sig-param"><span class="n">n</span><span class="o">=</span><span class="default_value">2048</span></em><span class="sig-paren">)</span><a class="reference internal" href="../_modules/data/utils.html#mol2image"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#data.utils.mol2image" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<dl class="py function">
<dt id="data.utils.pad_sequences">
<code class="sig-prename descclassname">data.utils.</code><code class="sig-name descname">pad_sequences</code><span class="sig-paren">(</span><em class="sig-param"><span class="n">seqs</span></em>, <em class="sig-param"><span class="n">max_length</span><span class="o">=</span><span class="default_value">None</span></em>, <em class="sig-param"><span class="n">pad_symbol</span><span class="o">=</span><span class="default_value">' '</span></em><span class="sig-paren">)</span><a class="reference internal" href="../_modules/data/utils.html#pad_sequences"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#data.utils.pad_sequences" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<dl class="py function">
<dt id="data.utils.process_graphs">
<code class="sig-prename descclassname">data.utils.</code><code class="sig-name descname">process_graphs</code><span class="sig-paren">(</span><em class="sig-param"><span class="n">smiles</span></em>, <em class="sig-param"><span class="n">node_attributes</span></em>, <em class="sig-param"><span class="n">get_atomic_attributes</span></em>, <em class="sig-param"><span class="n">edge_attributes</span></em>, <em class="sig-param"><span class="n">get_bond_attributes</span><span class="o">=</span><span class="default_value">None</span></em>, <em class="sig-param"><span class="n">kekulize</span><span class="o">=</span><span class="default_value">True</span></em><span class="sig-paren">)</span><a class="reference internal" href="../_modules/data/utils.html#process_graphs"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#data.utils.process_graphs" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<dl class="py function">
<dt id="data.utils.process_smiles">
<code class="sig-prename descclassname">data.utils.</code><code class="sig-name descname">process_smiles</code><span class="sig-paren">(</span><em class="sig-param"><span class="n">smiles</span></em>, <em class="sig-param"><span class="n">sanitized</span><span class="o">=</span><span class="default_value">False</span></em>, <em class="sig-param"><span class="n">target</span><span class="o">=</span><span class="default_value">None</span></em>, <em class="sig-param"><span class="n">augment</span><span class="o">=</span><span class="default_value">False</span></em>, <em class="sig-param"><span class="n">pad</span><span class="o">=</span><span class="default_value">True</span></em>, <em class="sig-param"><span class="n">tokenize</span><span class="o">=</span><span class="default_value">True</span></em>, <em class="sig-param"><span class="n">tokens</span><span class="o">=</span><span class="default_value">None</span></em>, <em class="sig-param"><span class="n">flip</span><span class="o">=</span><span class="default_value">False</span></em>, <em class="sig-param"><span class="n">allowed_tokens</span><span class="o">=</span><span class="default_value">None</span></em><span class="sig-paren">)</span><a class="reference internal" href="../_modules/data/utils.html#process_smiles"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#data.utils.process_smiles" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<dl class="py function">
<dt id="data.utils.read_smi_file">
<code class="sig-prename descclassname">data.utils.</code><code class="sig-name descname">read_smi_file</code><span class="sig-paren">(</span><em class="sig-param"><span class="n">filename</span></em>, <em class="sig-param"><span class="n">unique</span><span class="o">=</span><span class="default_value">True</span></em><span class="sig-paren">)</span><a class="reference internal" href="../_modules/data/utils.html#read_smi_file"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#data.utils.read_smi_file" title="Permalink to this definition">¶</a></dt>
<dd><blockquote>
<div><p>Reads SMILES from file. File must contain one SMILES string per line
with</p>
</div></blockquote>
<dl>
<dt>token in the end of the line.</dt><dd><dl class="simple">
<dt>Args:</dt><dd><p>filename (str): path to the file
unique (bool): return only unique SMILES</p>
</dd>
<dt>Returns:</dt><dd><p>smiles (list): list of SMILES strings from specified file.
success (bool): defines whether operation
was successfully completed or not.</p>
</dd>
</dl>
<p>If ‘unique=True’ this list contains only unique copies.</p>
</dd>
</dl>
</dd></dl>

<dl class="py function">
<dt id="data.utils.read_smiles_property_file">
<code class="sig-prename descclassname">data.utils.</code><code class="sig-name descname">read_smiles_property_file</code><span class="sig-paren">(</span><em class="sig-param"><span class="n">path</span></em>, <em class="sig-param"><span class="n">cols_to_read</span></em>, <em class="sig-param"><span class="n">delimiter</span><span class="o">=</span><span class="default_value">','</span></em>, <em class="sig-param"><span class="n">keep_header</span><span class="o">=</span><span class="default_value">False</span></em><span class="sig-paren">)</span><a class="reference internal" href="../_modules/data/utils.html#read_smiles_property_file"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#data.utils.read_smiles_property_file" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<dl class="py function">
<dt id="data.utils.sanitize_smiles">
<code class="sig-prename descclassname">data.utils.</code><code class="sig-name descname">sanitize_smiles</code><span class="sig-paren">(</span><em class="sig-param"><span class="n">smiles</span></em>, <em class="sig-param"><span class="n">canonize</span><span class="o">=</span><span class="default_value">True</span></em>, <em class="sig-param"><span class="n">min_atoms</span><span class="o">=</span><span class="default_value">- 1</span></em>, <em class="sig-param"><span class="n">max_atoms</span><span class="o">=</span><span class="default_value">- 1</span></em>, <em class="sig-param"><span class="n">return_num_atoms</span><span class="o">=</span><span class="default_value">False</span></em>, <em class="sig-param"><span class="n">allowed_tokens</span><span class="o">=</span><span class="default_value">None</span></em>, <em class="sig-param"><span class="n">allow_charges</span><span class="o">=</span><span class="default_value">False</span></em>, <em class="sig-param"><span class="n">return_max_len</span><span class="o">=</span><span class="default_value">False</span></em>, <em class="sig-param"><span class="n">logging</span><span class="o">=</span><span class="default_value">'warn'</span></em><span class="sig-paren">)</span><a class="reference internal" href="../_modules/data/utils.html#sanitize_smiles"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#data.utils.sanitize_smiles" title="Permalink to this definition">¶</a></dt>
<dd><p>Takes list of SMILES strings and returns list of their sanitized versions.
For definition of sanitized SMILES check
<a class="reference external" href="http://www.rdkit.org/docs/api/rdkit.Chem.rdmolops-module.html#SanitizeMol">http://www.rdkit.org/docs/api/rdkit.Chem.rdmolops-module.html#SanitizeMol</a></p>
<blockquote>
<div><dl class="simple">
<dt>Args:</dt><dd><p>smiles (list): list of SMILES strings
canonize (bool): parameter specifying whether to return
canonical SMILES or not.
min_atoms (int): minimum allowed number of atoms
max_atoms (int): maxumum allowed number of atoms
return_num_atoms (bool): return additional array of atom numbers
allowed_tokens (iterable, optional): allowed tokens set
allow_charges (bool): allow nonzero charges of atoms
logging (“warn”, “info”, “none”): logging level</p>
</dd>
<dt>Output:</dt><dd><p>new_smiles (list): list of SMILES and NaNs if SMILES string is
invalid or unsanitized.
If ‘canonize = True’, return list of canonical SMILES.</p>
</dd>
</dl>
<p>When ‘canonize = True’ the function is analogous to:
canonize_smiles(smiles, sanitize=True).</p>
</div></blockquote>
</dd></dl>

<dl class="py function">
<dt id="data.utils.save_smi_to_file">
<code class="sig-prename descclassname">data.utils.</code><code class="sig-name descname">save_smi_to_file</code><span class="sig-paren">(</span><em class="sig-param"><span class="n">filename</span></em>, <em class="sig-param"><span class="n">smiles</span></em>, <em class="sig-param"><span class="n">unique</span><span class="o">=</span><span class="default_value">True</span></em><span class="sig-paren">)</span><a class="reference internal" href="../_modules/data/utils.html#save_smi_to_file"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#data.utils.save_smi_to_file" title="Permalink to this definition">¶</a></dt>
<dd><p>Takes path to file and list of SMILES strings and writes SMILES
to the specified file.</p>
<blockquote>
<div><dl class="simple">
<dt>Args:</dt><dd><p>filename (str): path to the file
smiles (list): list of SMILES strings
unique (bool): parameter specifying whether to write
only unique copies or not.</p>
</dd>
<dt>Output:</dt><dd><p>success (bool): defines whether operation
was successfully completed or not.</p>
</dd>
</dl>
</div></blockquote>
</dd></dl>

<dl class="py function">
<dt id="data.utils.save_smiles_property_file">
<code class="sig-prename descclassname">data.utils.</code><code class="sig-name descname">save_smiles_property_file</code><span class="sig-paren">(</span><em class="sig-param"><span class="n">path</span></em>, <em class="sig-param"><span class="n">smiles</span></em>, <em class="sig-param"><span class="n">labels</span></em>, <em class="sig-param"><span class="n">delimiter</span><span class="o">=</span><span class="default_value">','</span></em><span class="sig-paren">)</span><a class="reference internal" href="../_modules/data/utils.html#save_smiles_property_file"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#data.utils.save_smiles_property_file" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<dl class="py function">
<dt id="data.utils.seq2tensor">
<code class="sig-prename descclassname">data.utils.</code><code class="sig-name descname">seq2tensor</code><span class="sig-paren">(</span><em class="sig-param"><span class="n">seqs</span></em>, <em class="sig-param"><span class="n">tokens</span></em>, <em class="sig-param"><span class="n">flip</span><span class="o">=</span><span class="default_value">True</span></em><span class="sig-paren">)</span><a class="reference internal" href="../_modules/data/utils.html#seq2tensor"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#data.utils.seq2tensor" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<dl class="py function">
<dt id="data.utils.time_since">
<code class="sig-prename descclassname">data.utils.</code><code class="sig-name descname">time_since</code><span class="sig-paren">(</span><em class="sig-param"><span class="n">since</span></em><span class="sig-paren">)</span><a class="reference internal" href="../_modules/data/utils.html#time_since"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#data.utils.time_since" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

</div>
</div>


           </div>
           
          </div>
          <footer>
  
    <div class="rst-footer-buttons" role="navigation" aria-label="footer navigation">
      
        <a href="criterion.html" class="btn btn-neutral float-right" title="criterion" accesskey="n" rel="next">Next <span class="fa fa-arrow-circle-right"></span></a>
      
      
        <a href="layers.html" class="btn btn-neutral float-left" title="layers" accesskey="p" rel="prev"><span class="fa fa-arrow-circle-left"></span> Previous</a>
      
    </div>
  

  <hr/>

  <div role="contentinfo">
    <p>
        &copy; Copyright 2018, Mariya Popova

    </p>
  </div>
  Built with <a href="http://sphinx-doc.org/">Sphinx</a> using a <a href="https://github.com/rtfd/sphinx_rtd_theme">theme</a> provided by <a href="https://readthedocs.org">Read the Docs</a>. 

</footer>

        </div>
      </div>

    </section>

  </div>
  


  <script type="text/javascript">
      jQuery(function () {
          SphinxRtdTheme.Navigation.enable(true);
      });
  </script>

  
  
    
    

  <style>
    /* Sidebar header (and topbar for mobile) */
    .wy-side-nav-search, .wy-nav-top {
      background: #99badd;
    }
  </style>


</body>
</html>